<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="IMP平台订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="impOrderNo">
              <a-input v-model="model.impOrderNo" placeholder="请输入IMP平台订单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="IMP平台支付流水号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="impJnlNo">
              <a-input v-model="model.impJnlNo" placeholder="请输入IMP平台支付流水号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商户订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mechantOrerNo">
              <a-input v-model="model.mechantOrerNo" placeholder="请输入商户订单号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tranTime">
              <a-input v-model="model.tranTime" placeholder="请输入交易时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="业务类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bizType">
              <a-input v-model="model.bizType" placeholder="请输入业务类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="消费者账户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custAcct">
              <a-input v-model="model.custAcct" placeholder="请输入消费者账户"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="订单金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderAmount">
              <a-input v-model="model.orderAmount" placeholder="请输入订单金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商家实收" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="realAmount">
              <a-input v-model="model.realAmount" placeholder="请输入商家实收"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="红包" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bonusAmount">
              <a-input v-model="model.bonusAmount" placeholder="请输入红包"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商家优惠" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="discountAmount">
              <a-input v-model="model.discountAmount" placeholder="请输入商家优惠"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="券核销金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="couponsAmount">
              <a-input v-model="model.couponsAmount" placeholder="请输入券核销金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="卡消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cardAmount">
              <a-input v-model="model.cardAmount" placeholder="请输入卡消费金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="服务费" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargeAmount">
              <a-input v-model="model.chargeAmount" placeholder="请输入服务费"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分润" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="profitAmount">
              <a-input v-model="model.profitAmount" placeholder="请输入分润"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="订单详情" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderDesc">
              <a-input v-model="model.orderDesc" placeholder="请输入订单详情"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="渠道类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="channel">
              <a-input v-model="model.channel" placeholder="请输入渠道类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="商户退款单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="refundOrderNo">
              <a-input v-model="model.refundOrderNo" placeholder="请输入商户退款单号"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'TempleDzJxyhDetailForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/temple.pay/templeDzJxyhDetail/add",
          edit: "/temple.pay/templeDzJxyhDetail/edit",
          queryById: "/temple.pay/templeDzJxyhDetail/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>